<template>
  <div class="root">
      <div v-for="item in drawerList"
          :key="item.index" :class="`item ${currentIndex===item.index?'currentItem':''}`" @click="changeIndex(item.index)">
          {{item.name}}
        </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    drawerList: {
        type: Array,
      	default() {
            return [];
        }
    },
    currentIndex:{
          type: Number,
          default:0
    }
  },
  data() {
    return {};
  },
  methods: {
      changeIndex(index){
          if(index!==this.currentIndex){
            this.$emit('change',index);
          }
      }

  },
  created() {}
};
</script>

<style scoped  lang="scss">
.root {
    display: flex;
    flex-direction: column;
    min-height: 400px;
    width: 150px;
    border:1px solid #ccc;
    justify-content: center;
    align-items: center;
    .item{
        width: 120px;
        padding: 10px 0 ;
        text-align: center;
        border:1px solid #ccc;
        margin: 15px 0;
        border-radius: 5px;
        font-size: 15px;
    }
    .currentItem{
        background: cornflowerblue;
        color: white;
        border: 0;
    }
}

</style>
